package thread;

/**
 * sleep方法要求我们必须处理异常
 */
public class SleepDemo2 {
    public static void main(String[] args) {
        Thread lin = new Thread("lin:") {
            public void run() {
                System.out.println(getName()+"美容完说一觉");
                try {
                    Thread.sleep(50000000);
                } catch (InterruptedException e) {
                    System.out.println(getName()+"干嘛呢 都破相了");
                }
                System.out.println(getName()+"醒了");
            }
        };
        Thread huang = new Thread("黄:") {
            public void run(){
                System.out.println(getName()+"小锤40"+"大锤80");
                for (int i = 0; i < 5; i++) {
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        throw new RuntimeException(e);
                    }
                    System.out.println("80");
                }
                System.out.println("砸玩了");
                lin.interrupt();  //中断睡眠
            }
        };
        lin.start();
        huang.start();
    }
}
